<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="../css/animate.css">
  <script src="../js/vue.js"></script>
  <style>
    * {
      padding: 0;
      margin: 0;
      box-sizing: border-box;
    }

    html,
    body {
      width: 100vw;
      height: 100vh;
    }
  </style>
</head>

<body>
  <!-- 
    定义入场和离场时的动画
      enter-active-class
      leave-active-class
    
    必须要带上基本类
      animated

    定义动画的时间
      duration

    分别设置入场和离场的时间
    :duration="{enter:0,leave:400}" 
   -->
  <div id="app">
    <input type="button" value="点击" @click="add">

    <transition enter-active-class="bounceIn" leave-active-class="bounceOut" :duration="1000">
      <h1 v-show="flag" class="animated">也可以放到我自己身上，只写一次</h1>
    </transition>

    <transition enter-active-class="bounceIn" leave-active-class="bounceOut" :duration="{enter:0,leave:400}">
      <h1 v-show="flag" class="animated">分别定义入场和出场的时间</h1>
    </transition>
  </div>
</body>
<script>
  const vm = new Vue({
    el: "#app",
    data: {
      flag: true
    },
    methods: {
      add() {
        this.flag = !this.flag;
      }
    }
  });
</script>

</html>